package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dto.SensitiveDto;
import com.heima.model.admin.pojo.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author TheCai
 * @date 2021/5/24 10:58
 **/
@Api(value = "敏感词设置",tags = "敏感词设置API")
@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {
    @Autowired
   private AdSensitiveService adSensitiveService;

    /** 敏感词分页列表 */
    @ApiOperation("敏感词分页列表")
    @PostMapping("/list")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDto dto) {
        return adSensitiveService.list(dto);
    }
    @ApiOperation("敏感词新增")
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }
    @ApiOperation("敏感词修改")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.amend(adSensitive);
    }
    @ApiOperation("敏感词删除")
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return adSensitiveService.deleteById(id);
    }

}
